package com.example.dante.a17376060_wanghaikang_finaltest.cn.example.main.cn.example.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.dante.a17376060_wanghaikang_finaltest.R;
import com.example.dante.a17376060_wanghaikang_finaltest.cn.example.main.cn.example.adapter.KindsAdapter;
import com.example.dante.a17376060_wanghaikang_finaltest.cn.example.main.cn.example.domain.Kinds;

import java.util.ArrayList;
import java.util.List;

public class FragmentKinds extends Fragment {

    View view;
    private DrawerLayout mDrawerLayout;
    private Kinds[] kinds={new Kinds("军事",R.drawable.jushi),new Kinds("国际",R.drawable.guoji),new Kinds("娱乐",R.drawable.yule),
    new Kinds("游戏",R.drawable.youxi),new Kinds("体育",R.drawable.tiyu),new Kinds("科技",R.drawable.keji),new Kinds("电影",
            R.drawable.dianying),new Kinds("财经",R.drawable.caijing)};
    private List<Kinds> kindsList=new ArrayList<>();
    private KindsAdapter adapter;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view=inflater.inflate(R.layout.fragment_kinds,container,false);
        for(int i=0;i<kinds.length;i++){
            kindsList.add(kinds[i]);
        }
        RecyclerView recyclerView=view.findViewById(R.id.kinds_view);
        GridLayoutManager layoutManager=new GridLayoutManager(getActivity(),2);
        recyclerView.setLayoutManager(layoutManager);
        adapter=new KindsAdapter(kindsList);
        recyclerView.setAdapter(adapter);
        return view;
    }
}
